﻿using System.Web.Mvc;
using System.Web.Routing;
using EPiMVC.Routing;
using EPiMVC.Templates.Web.Infrastructure;
using PageTypeBuilder;
using PageTypeBuilder.Activation.StructureMap;
using StructureMap;

namespace EPiMVC.Templates.Web
{
    public class Global : EPiServer.Global
    {
        protected void Application_Start()
        {
            IContainer container = new Container(new StructureMapConfiguration());

            ControllerBuilder.Current.SetControllerFactory(new StructureMapControllerFactory(container));

            PageTypeResolver.Instance.Activator = new StructureMapTypedPageActivator(container);

            RegisterRoutes(RouteTable.Routes);
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.Add(new EPiServerRoute());

        }

        
    }
}